package fr.grassaud.hmvc.vaadin.home;

import fr.grassaud.hmvc.component.ControlledModel;
import fr.grassaud.hmvc.component.ControlledView;
import fr.grassaud.hmvc.component.Controller;
import fr.grassaud.hmvc.event.OnInit;
import fr.grassaud.hmvc.event.OnViewEvent;
import fr.grassaud.hmvc.spring.component.SpringBean;
import fr.grassaud.hmvc.vaadin.component.SimpleService;

@Controller
public class HomeController {

    @ControlledView
    private HomeView view;

    @ControlledModel
    private HomeModel model;

    @SpringBean
    private SimpleService service;

    @OnInit
    public void init() {
	String label = model.getLabel();
	view.setLabel(label + service.getData());
    }

    @OnViewEvent(name = ChangeLabelEvent.NAME)
    protected void changeLabel(ChangeLabelEvent event) {
	model.setLabel();
	view.setLabel(model.getLabel() + " " + service.getData());
    }

}
